#ifndef _COMMUNICATE_H_
#define _COMMUNICATE_H_

#define sc95f_HAS_USCI5 (defined (SC95F8x6x) || defined (SC95F7x6x)  || defined (SC95F8x1xB) || defined (SC95F7x1xB) || defined (SC95F7619B))

#include <stdlib.h>
#include <INTRINS.H>
#include "CommunicateConfig.h"
#include "sc95f_uart0.h"
#include "sc95f_usci0.h"
#include "sc95f_usci1.h"
#include "sc95f_usci2.h"
#include "sc95f_usci3.h"
#include "sc95f_usci4.h"
#if sc95f_HAS_USCI5
#include "sc95f_usci5.h"
#endif

typedef struct 
{
    bool send_flag;
    uint16_t begin_pointer;
    uint16_t end_pointer;
    uint8_t BUF[Communicate_BufSize];
}Communicate;

#define Communicate_Uart0 0
#define Communicate_USCI0 1
#define Communicate_USCI1 2
#define Communicate_USCI2 3
#define Communicate_USCI3 4
#define Communicate_USCI4 5
#define Communicate_USCI5 6

#define UART_Mode_10B 0x40 /* USCIx_UART_Mode_10B = 0x40 */
#define UART_Mode_11B 0x80 /* USCIx_UART_Mode_11B = 0x80 */

#define UART_RX_ENABLE 0x10 /* USCIx_UART_RX_ENABLE = 0x10 */
#define UART_RX_DISABLE 0x00  /* USCIx_UART_RX_DISABLE = 0x00 */

void Communicate_init(uint8_t clinet);
void Communicate_initSet(uint8_t clinet, uint32_t Fsys, uint32_t BaudRate, uint8_t UartMode, uint8_t ClockMode, uint8_t UartRxMode);
void Communicate_setBaud(uint8_t clinet, uint16_t baud);
uint16_t Communicate_available(uint8_t clinet);
bool Communicate_sendData8(uint8_t clinet, uint8_t data8);
uint8_t Communicate_receiveData8(uint8_t clinet);
void Communicate_sendString8(uint8_t clinet, uint8_t* str);
uint16_t Communicate_receiveString8(uint8_t clinet, uint8_t* str, uint16_t sizestr);

#endif
